<script>
import axios, {request} from "axios";
import global from "../../views/global/global";
export default {
  name: "UseSealManagement",
  data() {
    return {
      realName:global.user.realName,
      seal: {
        applicantName:global.user.realName,
        applicationDate:new Date(),
        department:global.user.departmentName,
        sealName:'',
        reason:'',
      }
    }
  },
  methods: {
    getData() {
      if(this.seal.sealName === null || this.seal.sealName === undefined || this.seal.sealName === ''){
        this.$message({
          type: 'warning',
          message: '选择用章类型!'
        });
        return;
      }
      if(this.seal.reason === null || this.seal.reason === ''){
        this.$message({
          type: 'warning',
          message: '选择用章事由!'
        });
        return;
      }
      this.$confirm('确定提交吗？', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {

      axios.post("/oa/seanlmana/addition", this.seal).then((res) => {
        console.log(res.data.result)
        if (res.data.result === "true") {
          this.$message({
            type: 'success',
            message: '申请成功!'
          });
          this.$router.push('/HomePageView')
        } else {
          this.$message({
            type: 'error',
            message: '申请失败!'
          });
        }
      })
    }).catch(
          () => {
            this.$message({
              type: 'info',
              message: '已取消'
            });
          }
      )
    },
    cancel() {
      // 返回到我的桌面
      this.$router.push('/HomePageView')
    }
  }
}
</script>

<template>
  <div class="titleBox">
    用章管理
  </div>

  <el-form
      label-width="auto"
      :model="book"
      style="max-width: 600px"
  >
    <el-form-item label="姓名" >
      <span>{{seal.applicantName}}</span>
    </el-form-item>

    <el-form-item label="申请时间" >
      <el-date-picker disabled
                      v-model="seal.applicationDate"
                      type="datetime"
      />
    </el-form-item>

    <el-form-item label="部门">
      <span>{{seal.department}}</span>
    </el-form-item>

    <el-form-item label="用章类型">
      <el-select v-model="seal.sealName" placeholder="用章类型" style="width: 240px">
        <el-option label="财务章" value="财务章"/>
        <el-option label="人事章" value="人事章"/>
        <el-option label="合同章" value="合同章"/>
        <el-option label="技术章" value="技术章"/>
        <el-option label="销售章" value="销售章"/>
      </el-select>
    </el-form-item>

    <el-form-item label="用章事由">
      <el-select v-model="seal.reason" placeholder="用章事由" style="width: 240px" >
        <el-option label="合同盖章" value="合同盖章"/>
        <el-option label="入职合同" value="入职合同"/>
        <el-option label="市场合同" value="市场合同"/>
        <el-option label="项目合同" value="项目合同"/>
        <el-option label="销售合同" value="销售合同"/>
      </el-select>
    </el-form-item>

    <el-form-item label="下一步审批人">
      <el-select v-model="seal.applicantName" placeholder="审批人" style="width: 240px">
        <!--        默认选中当前用户-->
        <el-option
            :key="this.realName"
            :label="this.realName"
            :value="this.realName"
        />
      </el-select>

    </el-form-item>
    <el-button type="primary" @click="getData()">提交</el-button>
    <el-button @click="cancel">取消</el-button>
  </el-form>

</template>

<style scoped lang="less">



</style>
